package myTest.classes

//密封类隐式是一个无法实例化的抽象类。只能在类中被继承
sealed class SealedClass {

    class First : SealedClass()

    class Second : SealedClass()

    class Third : SealedClass()

}

fun main() {

    val type: SealedClass = SealedClass.First()
    //密封类可以减少else分支
    when (type) {
        is SealedClass.First -> println("第一种类型")
        is SealedClass.Second -> println("第二种类型")
        is SealedClass.Third -> println("第三种类型")
    }

}
